import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Ordered months
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
          'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
carbon_values = [109.97] * 12  # Constant value for each month

# Create DataFrame with correct order
df = pd.DataFrame({
    'Month': pd.Categorical(months, categories=months, ordered=True),
    'Carbon_Intensity': carbon_values
})
df['Row'] = '2024'  # dummy single row

# Pivot for heatmap
heatmap_data = df.pivot(index='Row', columns='Month', values='Carbon_Intensity')

# Plot
plt.figure(figsize=(14, 2))
ax = sns.heatmap(
    heatmap_data,
    cmap='RdYlGn_r',
    cbar=True,
    vmin=0,
    vmax=300,
    cbar_kws={
        'orientation': 'horizontal',
        'label': 'Carbon Intensity [gCO₂/kWh]',
        'pad': 0.15  # slight spacing from the plot
    }
)

# Clean up axes
ax.set_ylabel('')
ax.set_xlabel('')
ax.set_yticks([])

# Format x-axis (month) labels
plt.xticks(rotation=0, fontsize=12)

# Add custom label under months
plt.text(6, 1.10, 'Year (2024)', fontsize=12, ha='center')

# Title
plt.title('Yearly Carbon Intensity (Belgium 2024)', fontsize=16, fontweight='bold')
plt.tight_layout()
plt.show()
